﻿namespace Chapter02.DesginMode1 {
    public class WeatherData : ISubjuect {
        public List<IObserver> Observers { get; } = [];

        public float Temperature { get; set; }

        public float Humidity { get; set; }

        public float Pressure { get; set; }

        public void RegisterObserver(IObserver observer) {
            Observers.Add(observer);
        }

        public void RemoveObserver(IObserver observer) {
            Observers.Remove(observer);
        }

        public void NotifyObservers() {
            foreach (var observer in Observers) {
                observer.Update(Temperature, Humidity, Pressure);
            }
        }

        public void GetState() {

        }


        public void SetState(float temperature, float humidity, float pressure) {
            Temperature = temperature;
            Humidity = humidity;
            Pressure = pressure;
            NotifyObservers();
        }
    }
}
